package com.example.escloud;

import com.digiwin.escloud.test.bussiness.test.AbstarctTestV1;
import com.digiwin.escloud.test.core.common.CommonData;
import com.digiwin.escloud.test.core.entity.TestCaseEntity;
import org.springframework.http.HttpStatus;
import org.testng.annotations.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;

/**
 * @Author yanggld
 * @Date 2020/4/27-15:40
 */
public class TestDemo1 extends AbstarctTestV1 {

    @Test(description = "保存联系人")
    public void addContactTest(TestCaseEntity testCaseEntity) {
        execute(testCaseEntity, (response) -> {
            System.out.println("xxxx"+response.getBody().asString());
            assertThat(response.getStatusCode(), equalTo(HttpStatus.OK.value()));
        });
    }

    private Long categoryId = null;

    @Test(description = "保存分类")
    public void insertCategoryTest(TestCaseEntity testCaseEntity) {
        execute(testCaseEntity, (response) -> {
            System.out.println("保存分类"+response.getBody().asString());
            assertThat(response.getStatusCode(), equalTo(HttpStatus.OK.value()));

        });
    }


    private Long annId = null;

    @Test(description = "保存公告")
    public void saveAnnoTest(TestCaseEntity testCaseEntity) {
        execute(testCaseEntity, (response) -> {
            System.out.println("保存公告"+response.getBody().asString());
            assertThat(response.getStatusCode(), equalTo(HttpStatus.OK.value()));
            assertThat(response.getBody().jsonPath().getLong("id"), greaterThan(0L));
            annId = response.getBody().jsonPath().getLong("id");
            CommonData.sharedData.put("annId",annId);
        });
    }

    @Test(description = "xxxx")
    public void xxxx() {
        System.out.println("fafnaofjasodmaodod");
    }

    @Test(description = "获取公告阅读记录",dependsOnMethods = {"saveAnnoTest"} )
    public void getAnnReadDetailTest(TestCaseEntity entity){
        execute(entity, response -> {
            assertThat(response.getStatusCode(), equalTo(HttpStatus.OK.value()));
            System.out.println("获取公告阅读记录"+response.getBody().asString());
        });
    }


}